add utf8proc_unicode_version (#151)
authorSteven G. Johnson <stevenj@mit.edu>
Sat, 30 Mar 2019 20:31:02 +0000 (16:31 -0400)
committerGitHub <noreply@github.com>
Sat, 30 Mar 2019 20:31:02 +0000 (16:31 -0400)
Makefile
data/Makefile
test/misc.c
utf8proc.c
utf8proc.h

index 79dd8a88a9f0d59075a07c36fe7eeda52432633a..e3310f7cfe2c4795a733d60606e2a07ed4846485 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,7 @@ AR?=ar
 CC?=gcc
 INSTALL=install
 FIND=find
+PERL=perl
 
 # compiler settings
 CFLAGS ?= -O2
@@ -154,7 +155,7 @@ test/custom: test/custom.c test/tests.o utf8proc.o utf8proc.h test/tests.h
        $(CC) $(UCFLAGS) $(LDFLAGS) test/custom.c test/tests.o utf8proc.o -o $@
 
 test/misc: test/misc.c test/tests.o utf8proc.o utf8proc.h test/tests.h
-       $(CC) $(UCFLAGS) $(LDFLAGS) test/misc.c test/tests.o utf8proc.o -o $@
+       $(CC) $(UCFLAGS) $(LDFLAGS) -DUNICODE_VERSION='"'`$(PERL) -ne "/^UNICODE_VERSION=/ and print $$';" data/Makefile`'"' test/misc.c test/tests.o utf8proc.o -o $@
 
 check: test/normtest data/NormalizationTest.txt test/graphemetest data/GraphemeBreakTest.txt test/printproperty test/case test/custom test/charwidth test/misc test/valid test/iterate bench/bench.c bench/util.c bench/util.h utf8proc.o
        $(MAKE) -C bench
index c824a9b80104bbeee62128b7dda79d50991d09d3..f5d1dd9064a5e9fad77053770182a9ef314cf99a 100644 (file)
@@ -21,7 +21,7 @@ utf8proc_data.c.new: data_generator.rb UnicodeData.txt GraphemeBreakProperty.txt
 CharWidths.txt: charwidths.jl EastAsianWidth.txt
        $(JULIA) charwidths.jl > $@
 
-# Unicode data version
+# Unicode data version (must also update utf8proc_unicode_version function)
 UNICODE_VERSION=12.0.0
 
 UnicodeData.txt:
index 56d81d54901161af623611ce0b7446ae938a67e8..8655233b05775d4ce7b9377ea4e9bd402580492a 100644 (file)
@@ -41,6 +41,10 @@ int main(void)
 {
     issue128();
     issue102();
+#ifdef UNICODE_VERSION
+    printf("Unicode version: Makefile has %s, has API %s\n", UNICODE_VERSION, utf8proc_unicode_version());
+    check(!strcmp(UNICODE_VERSION, utf8proc_unicode_version()), "utf8proc_unicode_version mismatch");
+#endif
     printf("Misc tests SUCCEEDED.\n");
     return 0;
 }
index 98e754d1b38b1c406f5fa3009bd9b8b9f8c86f87..5de128a0019e9ced4ddbcaec56f9ec36c7d41f77 100644 (file)
@@ -100,6 +100,10 @@ UTF8PROC_DLLEXPORT const char *utf8proc_version(void) {
   return STRINGIZE(UTF8PROC_VERSION_MAJOR) "." STRINGIZE(UTF8PROC_VERSION_MINOR) "." STRINGIZE(UTF8PROC_VERSION_PATCH) "";
 }
 
+UTF8PROC_DLLEXPORT const char *utf8proc_unicode_version(void) {
+  return "12.0.0";
+}
+
 UTF8PROC_DLLEXPORT const char *utf8proc_errmsg(utf8proc_ssize_t errcode) {
   switch (errcode) {
     case UTF8PROC_ERROR_NOMEM:
index d12b721a6c5245d7633218a1de61dd24d78f63a2..9df181152b75086d89d9c7cc5acf828b48f5da43 100644 (file)
@@ -408,6 +408,11 @@ UTF8PROC_DLLEXPORT extern const utf8proc_int8_t utf8proc_utf8class[256];
  */
 UTF8PROC_DLLEXPORT const char *utf8proc_version(void);
 
+/**
+ * Returns the utf8proc supported Unicode version as a string MAJOR.MINOR.PATCH.
+ */
+UTF8PROC_DLLEXPORT const char *utf8proc_unicode_version(void);
+
 /**
  * Returns an informative error string for the given utf8proc error code
  * (e.g. the error codes returned by @ref utf8proc_map).